import os
from configparser import ConfigParser


class ConfUtil(object):
    def __init__(self):
        self.conf = ConfigParser()
        self.parent_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

        
    
    def get_tokens(self,token_belong):
        conf_filename = f"tokens.properties"
        
        conf_file = os.path.join(os.path.join(self.parent_dir_path, "resources"), conf_filename)
        if not os.path.isfile(conf_file):
            raise FileExistsError("配置文件[{0}]不存在!".format(conf_file))
        self.conf.read(conf_file, encoding='UTF-8')
        return self.conf.get(token_belong, "token")